import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/material.dart';
// ignore: depend_on_referenced_packages
export 'package:fluttertoast/fluttertoast.dart';
export './utils/logger.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:simple_music_app/core/utils.dart';
void musicFluttertoast(String msg) {
  Fluttertoast.showToast(
      msg: msg,
      toastLength: Toast.LENGTH_SHORT,
      gravity: ToastGravity.CENTER,
      timeInSecForIosWeb: 1,
      textColor: Colors.white,
      fontSize: 16.0);
}
Future<bool> storagePermission() async {
  final DeviceInfoPlugin info =
      DeviceInfoPlugin(); // import 'package:device_info_plus/device_info_plus.dart';
  final AndroidDeviceInfo androidInfo = await info.androidInfo;

  final int androidVersion = int.parse(androidInfo.version.release);
  bool havePermission = false;
  // Here you can use android api level
  // like android api level 33 = android 13
  // This way you can also find out how to request storage permission

  if (androidVersion >= 13) {
    final request = await [
      // Permission.videos,
      // Permission.photos,
      Permission.audio,
      Permission.storage
      //..... as needed
    ].request(); //import 'package:permission_handler/permission_handler.dart';

    havePermission =
        request.values.every((status) => status == PermissionStatus.granted);
  } else {
    final status = await Permission.storage.request();
    havePermission = status.isGranted;
  }

  if (!havePermission) {
    // if no permission then open app-setting
    await openAppSettings();
  }

  return havePermission;
}